#include "named_pipe.h"

int main() {
    cout << "client begin" << endl;
    int write_fd = open(NAMED_PIPE, O_WRONLY);
    cout << "client end" << endl;
    assert(write_fd >= 0);

    char buffer[1024];
    while (true) {
        cout << "please say# ";
        fgets(buffer, sizeof(buffer), stdin);
        if (strlen(buffer) > 0) {
            buffer[strlen(buffer) - 1] = '\0'; //把'\n'替换掉
        }

        ssize_t size = write(write_fd, buffer, strlen(buffer));
        assert(size == strlen(buffer));
        (void)size;
    }

    close(write_fd);
    return 0;
}